const Router = require('restify-router').Router;
const router = new Router();

const UserDao = require('../../models/user')

const R = require('../../utils/R')

router.post('', async (req, res, next) => {
	// 检查入参不能为空
	if (!req.body) {
		res.send(new R(400, '缺少参数', null))
		return next()
	}

	let objectId = req.body.objectId
	let tel = req.body.tel;

	let user = await UserDao.create({
		id: objectId,
		phone: tel,
	})

	res.send(new R(200, '注册成功', user))
	return next();
})

module.exports = router;
